/** layui-v2.5.7 自定义模块 */
layui.define(['jquery','layer'],function(exports){
	var $ = layui.jquery,layer = layui.layer;
	var cm={
			onOpen:function(){ alert("Console is opened"); },
			onClose:function(){ alert("Console is closed");},
			init:function(){
				var self = this,x = document.createElement('div'),isOpening = false,isOpened=false;
				Object.defineProperty(x, 'id', { get:function(){ if(!isOpening){ self.onOpen(); isOpening=true; } isOpened=true; } });
				setInterval(function(){ isOpened=false; console.info(x); console.clear(); if(!isOpened && isOpening){ self.onClose(); isOpening=false; } },200)
		}
	};
	var obj = {
		noEmbeddingThisPage: function(){ //禁止 通过嵌入 子页面方式打开本页面
			if(window.location.href !== window.top.location.href){ window.location.href = "/"; }
		},
		disOpenConsole: function(text){////禁止打开控制台的代码
			cm.onOpen = function(){
				try{//打开控制台，跳转到首页
					window.open('/',target='_self');
				}catch(err){
					var a = document.createElement("button"); a.onclick=function(){ window.open('/',target='_self'); } a.click();
				}
			};
			cm.onClose = function(){ console.log("Console is closed!!!!!"); };
			cm.init();
		}
	};
	//js防御调试模块
	exports('defense',obj);
})